package com.wardrobe.dao.address;

import com.wardrobe.domain.address.AddressBean;
import com.wardrobe.mapper.master.address.AddressMasterMapper;
import com.wardrobe.mapper.slave.address.AddressSlaveMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/11/14.
 */
@Service
public class AddressDao {
    @Autowired
    private AddressMasterMapper addressMasterMapper;
    @Autowired
    private AddressSlaveMapper addressSlaveMapper;

    public int insertAddress(AddressBean addressBean) {
        return addressMasterMapper.insertAddress(addressBean);
    }

    public int updateAddress(AddressBean addressBean) {
        return addressMasterMapper.updateAddress(addressBean);
    }

    public List<AddressBean> selectAddressByUserId(long userId) {
        return addressSlaveMapper.selectAddressByUserId(userId);
    }

    public AddressBean selectDefaultAddress(long userId) {
        return addressSlaveMapper.selectDefaultAddress(userId);
    }

    public int deleteAddress(long id){
        return addressMasterMapper.deleteAddress(id);
    }

    public AddressBean selectAddressById(long id){
        return addressSlaveMapper.selectAddressById(id);
    }
}
